from typing import Optional, Dict, Any, List
from pydantic import BaseModel

# 基本模型定义 - 不使用高级配置特性
class InputParameter(BaseModel):
    """输入参数模型"""
    name: str
    label: str
    type: str
    required: bool = False
    options: Optional[List[Dict[str, Any]]] = None
    max_length: Optional[int] = None
    default_value: Optional[Any] = None

class ToolParameter(BaseModel):
    """工具参数模型"""
    name: str
    label: str
    type: str
    required: bool = False
    default_value: Optional[Any] = None
    options: Optional[List[Dict[str, Any]]] = None

class ToolInfo(BaseModel):
    """工具信息模型"""
    name: str
    description: str
    parameters: List[ToolParameter]

class ApplicationInfo(BaseModel):
    """应用信息模型"""
    id: str
    name: str
    description: str
    mode: str
    icon: Optional[str] = None
    icon_background: Optional[str] = None
    enable_site: bool
    enable_api: bool
    enable_vision: bool = False
    enable_file_upload: bool = False
    enable_rag: bool = False
    api_parameters: Dict[str, Any] = {}
    model_config: Dict[str, Any] = {}
    feature_flags: Optional[Dict[str, bool]] = None

class BasicInfoResponse(BaseModel):
    """基本信息响应模型 - 对应GET /info接口"""
    name: str
    description: str = ""
    tags: List[str] = []

class ParametersResponse(BaseModel):
    """参数响应模型 - 对应GET /parameters接口"""
    opening_statement: str = ""
    suggested_questions: List[str] = []
    suggested_questions_after_answer: Dict[str, Any] = {"enabled": False}
    speech_to_text: Dict[str, Any] = {"enabled": False}
    retriever_resource: Dict[str, Any] = {"enabled": False}
    annotation_reply: Dict[str, Any] = {"enabled": False}
    user_input_form: List[Dict[str, Any]] = []
    file_upload: Optional[Dict[str, Any]] = None
    system_parameters: Optional[Dict[str, Any]] = None

class MetaResponse(BaseModel):
    """Meta信息响应模型 - 对应GET /meta接口"""
    tool_icons: Dict[str, Any] = {}

class InfoResponse(BaseModel):
    """信息响应模型"""
    app: ApplicationInfo
    parameters: ParametersResponse

class MessageAnnotation(BaseModel):
    """消息标注模型"""
    name: str
    value: Any
    metadata: Optional[Dict[str, Any]] = None

class AnnotationResponse(BaseModel):
    """标注响应模型"""
    annotations: List[MessageAnnotation]
